home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 001a / com_and3.zip / MKLOGON.CMD < prev    next >
OS/2 REXX Batch file  |  1989-10-03  |  7KB  |  265 lines

  1. ; ----- MkLogon: Create logon scripts for COM-AND
  2. ;
  3. ;    R.McG; 7/89, Chicago
  4. ; ----------------------------------------------------------------
  5. ; Usages:
  6. ;      S19 -----> Legend line
  7. ;      S18 -----> File name preamble for destination file
  8. ;      S17 -----> Carries the system ID
  9. ;      S16 -----> Carries the system password
  10. ;      S15 -----> System name
  11. ; -----------------------------------------------------------------------
  12. ;
  13. ;    Initialization
  14. ;
  15.    S19 = "MkLogon ver 1.0     " ; 20 chars long
  16.    LEGEND S19            ; Set initial legend
  17.    GOTO START            ; And continue
  18. ;
  19. ;    Escape - Clear all windows, and exit
  20. ;
  21. Escape:
  22.    DO                ; Close any open windows
  23.      WCLOSE
  24.      UNTIL FAILED
  25.    EXIT             ; End script
  26. ;
  27. ;    Draw the screen, and decide if we're linked
  28. ;
  29. Start:
  30.     WOPEN 0,10, 9,70 (default) Escape
  31.     ATSAY 0,12  (Default) " MkLogon "
  32.     ATSAY 1,12  (Default) "1) Create new PLINK logon"
  33.     ATSAY 2,12  (Default) "2) Create new UNISON logon"
  34.     ATSAY 3,12  (Default) "3) Create new GEnie logon"
  35.     ATSAY 4,12  (Default) "4) Create new Delphi logon"
  36.     ATSAY 5,12  (Default) "5) Create new CIS logon"
  37.     ATSAY 6,12  (Default) "6) Create new NWI logon"
  38.  
  39.     ATSAY 9,28  (Default) " Press ESC to terminate "
  40. ;
  41. ;    Wait for a keypress
  42. ;
  43. Main:
  44.    KEYGET S1            ; Read a single key
  45.    SWITCH S1
  46.       CASE "1"                  ; PLINK
  47.      S18 = "AHN"
  48.      S15 = "PLink"
  49.       ENDCASE
  50.       CASE "2"                  ; UNISON
  51.      S18 = "UNI"
  52.      S15 = "Unison"
  53.       ENDCASE
  54.       CASE "3"                  ; GEnie
  55.      S18 = "GEN"
  56.      S15 = "GEnie"
  57.       ENDCASE
  58.       CASE "4"                  ; Delphi
  59.      S18 = "DEL"
  60.      S15 = "Delphi"
  61.       ENDCASE
  62.       CASE "5"                  ; CIS
  63.      S18 = "CIS"
  64.      S15 = "CompuServe"
  65.       ENDCASE
  66.       CASE "6"                  ; NWI
  67.      S18 = "NWI"
  68.      S15 = "NWI"
  69.       ENDCASE
  70.  
  71.       DEFAULT
  72.     SOUND 100,100        ; Signal displeasure
  73.     GOTO Main        ; Try again
  74.       ENDCASE
  75.    ENDSWITCH
  76. ;
  77. ;    Prompt for an ID
  78. ;
  79.     GOSUB Get_ID        ; Request an ID
  80.     IF FAILED        ; Test return status
  81.        GOTO Main        ; Back to main query
  82.        ENDIF
  83.     S17 = S0        ; Save ID
  84.  
  85.     GOSUB Get_Psw        ; Request a Psw
  86.     IF FAILED        ; Test return status
  87.        GOTO Main        ; Back to main query
  88.        ENDIF
  89.     S16 = S0        ; Save PSW
  90. ;
  91. ;    Review the ID and password
  92. ;
  93.     PRESERVE S17        ; Preserve for display/write
  94.     PRESERVE S16        ; Preserve for display/write
  95.     GOSUB Review        ; Review ID and psw
  96.     IF FAILED        ; Test return status
  97.        GOTO Main        ; Back to main query
  98.        ENDIF
  99. ;
  100. ;    Create an unencrypted logon file
  101. ;
  102.     S10 = S18&"LOGON.CMD"
  103.     FOPENO S10 TEXT     ; Purge file if it exists
  104.     IF FAILED
  105.        S19 = "Error opening "*S10
  106.        GOTO Error        ; Exit if error
  107.        ENDIF
  108.     IF STRCMP S18 "GEN"     ; Special case for GEnie
  109.        S0 = "TRANSMIT `""*S17&","*S16*"!!`"!"
  110.        LENGTH S0 N0
  111.        WRITE S0 N0        ; Write a single line
  112.     ELSE            ; Everyone else
  113.        S0 = "TRANSMIT `""*S17*"!!`"!"
  114.        LENGTH S0 N0
  115.        WRITE S0 N0        ; Write a single line
  116.        S0 = "WAITFOR `"password`"!"
  117.        LENGTH S0 N0
  118.        WRITE S0 N0        ; Write a single line
  119.        S0 = "TRANSMIT `""*S16*"!!`"!"
  120.        LENGTH S0 N0
  121.        WRITE S0 N0        ; Write a single line
  122.        ENDIF
  123.     S0 = "IF FCALLED!"
  124.     LENGTH S0 N0
  125.     WRITE S0 N0        ; Write a single line
  126.     S0 = "   FRET!"
  127.     LENGTH S0 N0
  128.     WRITE S0 N0        ; Write a single line
  129.     S0 = "   ENDIF!"
  130.     LENGTH S0 N0
  131.     WRITE S0 N0        ; Write a single line
  132.     FCLOSEO         ; CLose the output file
  133. ;
  134. ;    Finally, ask if the file is to be encrypted
  135. ;
  136.     GOSUB Get_Encrypt    ; Ask for encryption
  137.     IF FAILED        ; Failure here
  138.        GOTO Main        ; .. means no encryption
  139.        ENDIF
  140. ;
  141. ;    Encrypt the file
  142. ;
  143.     S11 = S18&"LOGON.ENF"
  144.     ENCRYPT S10,S11,S0 SIMP ; Input, output, password, method
  145.     IF FAILED
  146.        S19 = "Encryption failed on "*S11
  147.        GOTO Error        ; Exit if error
  148.        ENDIF
  149.     DELETE S10        ; Delete unencrypted file
  150.     GOTO Main        ; And continue
  151. ;
  152. ; ----- Subroutine: Open a window and ask for an ID
  153. ;    SUCCESS/Failed returned to indicate ESCape
  154. ;    S0 returns the ID
  155. ;
  156. Get_ID:
  157.     WOPEN 10 10 13 70 (Default) TOP_ESC
  158.     ATSAY 10 ,12 (default)    " MkLogon ID "
  159.     ATSAY 11 ,11 (default)    " Please specify the ID for "*S15
  160.     ATSAY 13  30 (default) " Press ESC to exit "
  161.     ATGET 12, 12 (default) 54 S0
  162.     WCLOSE
  163.     ;
  164.     ;    If null response, return failed
  165.     ;
  166. End_Get:
  167.     SET SUCCESS ON        ; Default return
  168.     LJ S0            ; Left justify
  169.     IF NULL S0
  170.        SET SUCCESS OFF
  171.        ENDIF
  172.     RETURN
  173.     ;
  174.     ;    ESC hit during topic entry
  175.     ;
  176. TOP_ESC:
  177.     S0 = ""                 ; Make a null return
  178.     RETURN
  179. ;
  180. ; ----- Subroutine: Open a window and ask for a password
  181. ;    SUCCESS/Failed returned to indicate ESCape
  182. ;    S0 returns the password
  183. ;
  184. Get_Psw:
  185.     WOPEN 10 10 13 70 (Default) TOP_ESC
  186.     ATSAY 10 ,12 (default)    " MkLogon Password "
  187.     ATSAY 11 ,11 (default)    " Please specify the password for "*S15
  188.     ATSAY 13  30 (default) " Press ESC to exit "
  189.     ATGET 12, 12 (default) 54 S0
  190.     WCLOSE
  191.     ;
  192.     ;    If null response, return failed
  193.     ;
  194.     GOTO End_Get        ; Exit, setting SUCCESS/FAILURE
  195. ;
  196. ; ----- Subroutine: Review ID and password
  197. ;    SUCCESS/Failed returned to indicate ESCape
  198. ;
  199. Review:
  200.     WOPEN 10 10  16 70 (Default) TOP_ESC
  201.     ATSAY 10 ,12 (default)    " MkLogon Review "
  202.     ATSAY 11 ,12 (default)    " System:   "*S15
  203.     ATSAY 12 ,12 (default)    " ID:       "*S17
  204.     ATSAY 13 ,12 (default)    " Password: "*S16
  205.     ATSAY 15 ,12 (default)    " Is this correct? (y/n): "
  206.     ATSAY 16  30 (default) " Press ESC to cancel "
  207.     ATGET 15, 37 (default) 1  S0
  208.     WCLOSE
  209.     ;
  210.     ;    Interpret the response
  211.     ;
  212.     IF NULL S0 or FIND S0 "Y"
  213.        SET SUCCESS ON
  214.     ELSE
  215.        IF FIND S0 "N"
  216.           SET SUCCESS OFF
  217.        ELSE
  218.           SOUND 100,100
  219.           GOTO Review
  220.           ENDIF
  221.        ENDIF
  222.     RETURN
  223. ;
  224. ; ----- Subroutine: Ask for encryption
  225. ;    SUCCESS/Failed returned to indicate encryption y/n
  226. ;    IF SUCCESS, S0 returns the password
  227. ;
  228. Get_Encrypt:
  229.     WOPEN 10 10  16 70 (Default) TOP_ESC
  230.     ATSAY 10 ,12 (default)    " MkLogon Encrypt "
  231.     ATSAY 11 ,12 (default)    "If you wish to have the logon file encrypted, enter the"
  232.     ATSAY 12 ,12 (default)    "password here.  If you encrypt the file, you must have"
  233.     ATSAY 13 ,12 (default)    "the password everytime you wish to logon."
  234.     ATSAY 15 ,12 (default)    "Encryption password: "
  235.     ATSAY 16  37 (default) " Press ESC to skip "
  236.     ATGET 15, 32 (default) 32 S0
  237.     WCLOSE
  238.     ;
  239.     ;    Interpret the response
  240.     ;
  241.     IF NULL S0
  242.        SET SUCCESS OFF
  243.     ELSE
  244.        SET SUCCESS ON
  245.        ENDIF
  246.     RETURN
  247. ;
  248. ; ----- Fatal error.  Open a window, display a message, and exit
  249. ;    .. Note that this procedure terminates the script
  250. ;
  251. ;    S19 passes the error message
  252. ;
  253. Error:
  254.     WOPEN 10,10,12,70 (contrast) Err_Esc
  255.     ATSAY 10,12 (contrast) " Error "
  256.     ATSAY 11,12 (contrast) S19(0:55); Max msg width 55 chars
  257.     ATSAY 12,26 (contrast) " Press any key to continue "
  258.     ;
  259.     ;    Wait a keypress
  260.     ;
  261.     KEYGET S0            ; Wait for any key
  262. Err_Esc:
  263.     WCLOSE
  264.     EXIT
  265.